package edu.ccut.saturn.common.webcontext;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

@SuppressWarnings("unchecked")
public class MockEnumeration implements Enumeration {

	private Map map = null;

	private Iterator<String> index = null;

	public MockEnumeration() {

	}

	public MockEnumeration(Map map) {
		this.map = map;
		index = this.map.keySet().iterator();
	}

	public void setMap(Map map) {
		this.map = map;
		index = this.map.keySet().iterator();
	}

	public boolean hasMoreElements() {
		if (this.map != null) {
			return index.hasNext();
		}
		return false;
	}

	public Object nextElement() {
		if (this.map != null) {
			return index.next();
		}
		return false;
	}

}
